package ClientUI;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import javax.swing.WindowConstants;
import javax.swing.SwingUtilities;

import Protocol.user.BasePersonInfo;
import Protocol.user.BasePersonInfo_R;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class InfoEditFrame extends javax.swing.JFrame {
	private JPanel jPanel1;
	private JLabel jLabel3;
	private JLabel jLabel4;
	private JLabel jLabel5;
	private JLabel feedbackLabel;
	private JButton saveButton;
	private JComboBox classBox;
	private JLabel jLabel7;
	private JComboBox gradeBox;
	private JLabel jLabel6;
	private JComboBox typeBox;
	private JTextArea hobbyArea;
	private JTextArea sigArea;
	private JComboBox genderBox;
	private JLabel jLabel2;
	private JTextField nameField;
	private JLabel jLabel1;
	
	private ClientGUI	clientGui;

	/**
	* Auto-generated main method to display this JFrame
	*//*
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				InfoEditFrame inst = new InfoEditFrame();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}*/
	
	public InfoEditFrame(ClientGUI  cgui) {
		super();
		this.clientGui = cgui;
		initGUI();
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				jPanel1 = new JPanel();
				getContentPane().add(jPanel1, BorderLayout.CENTER);
				jPanel1.setLayout(null);
				{
					jLabel1 = new JLabel();
					jPanel1.add(jLabel1);
					jLabel1.setText("name");
					jLabel1.setBounds(14, 23, 32, 17);
				}
				{
					nameField = new JTextField();
					jPanel1.add(nameField);
					nameField.setText("your name");
					nameField.setBounds(64, 23, 68, 24);
				}
				{
					jLabel2 = new JLabel();
					jPanel1.add(jLabel2);
					jLabel2.setText("gender");
					jLabel2.setBounds(12, 64, 42, 17);
				}
				{
					ComboBoxModel genderBoxModel = 
						new DefaultComboBoxModel(
								new String[] { "man", "woman" });
					genderBox = new JComboBox();
					jPanel1.add(genderBox);
					genderBox.setModel(genderBoxModel);
					genderBox.setBounds(66, 64, 66, 24);
				}
				{
					jLabel3 = new JLabel();
					jPanel1.add(jLabel3);
					jLabel3.setText("signature");
					jLabel3.setBounds(12, 110, 54, 17);
				}
				{
					sigArea = new JTextArea();
					jPanel1.add(sigArea);
					sigArea.setText("your signature here");
					sigArea.setBounds(14, 139, 117, 111);
				}
				{
					jLabel4 = new JLabel();
					jPanel1.add(jLabel4);
					jLabel4.setText("hobby");
					jLabel4.setBounds(168, 110, 37, 17);
				}
				{
					hobbyArea = new JTextArea();
					jPanel1.add(hobbyArea);
					hobbyArea.setText("your hobby here");
					hobbyArea.setBounds(168, 139, 106, 111);
				}
				{
					jLabel5 = new JLabel();
					jPanel1.add(jLabel5);
					jLabel5.setText("status");
					jLabel5.setBounds(275, 23, 34, 17);
				}
				{
					ComboBoxModel typeBoxModel = 
						new DefaultComboBoxModel(
								new String[] { "admin", "student", "teacher", "instructor", "committee" });
					typeBox = new JComboBox();
					jPanel1.add(typeBox);
					typeBox.setModel(typeBoxModel);
					typeBox.setBounds(317, 23, 55, 24);
				}
				{
					jLabel6 = new JLabel();
					jPanel1.add(jLabel6);
					jLabel6.setText("grade");
					jLabel6.setBounds(158, 68, 35, 17);
				}
				{
					ComboBoxModel gradeBoxModel = 
						new DefaultComboBoxModel(
								new String[] { "1", "2", "3", "4" });
					gradeBox = new JComboBox();
					jPanel1.add(gradeBox);
					gradeBox.setModel(gradeBoxModel);
					gradeBox.setBounds(205, 64, 54, 24);
				}
				{
					jLabel7 = new JLabel();
					jPanel1.add(jLabel7);
					jLabel7.setText("class");
					jLabel7.setBounds(158, 26, 35, 17);
				}
				{
					ComboBoxModel classBoxModel = 
						new DefaultComboBoxModel(
								new String[] { "1", "2", "3", "4" });
					classBox = new JComboBox();
					jPanel1.add(classBox);
					classBox.setModel(classBoxModel);
					classBox.setBounds(205, 22, 58, 24);
				}
				{
					saveButton = new JButton();
					jPanel1.add(saveButton);
					saveButton.setText("Save");
					saveButton.setBounds(309, 221, 64, 24);
					saveButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent evt) {
							saveButtonActionPerformed(evt);
						}
					});
				}
				{
					feedbackLabel = new JLabel();
					jPanel1.add(feedbackLabel);
					feedbackLabel.setText("feedback");
					feedbackLabel.setBounds(309, 174, 54, 17);
				}
			}
			pack();
			setSize(400, 300);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	private void saveButtonActionPerformed(ActionEvent evt) {
		//System.out.println("saveButton.actionPerformed, event="+evt);
		//TODO add your code for saveButton.actionPerformed
		BasePersonInfo	bpi = new BasePersonInfo();
		bpi.setName(this.nameField.getText());
		//bpi.setType((String)(this.typeBox.getSelectedItem()));
		bpi.setSignature(this.sigArea.getText());
		bpi.setGender(this.genderBox.getSelectedIndex());
		BasePersonInfo_R	bpir = new BasePersonInfo_R();
		bpir.setBpi(bpi);
		this.feedbackLabel.setText("success !");
		clientGui.getClient().getClientNet().sendMsgTo(clientGui.getClient().getClientData().getServer_basic(), bpir);
		this.dispose();
		//bpi.set
	}

}
